<?php

/**
 * Represents response of API method call.
 * Indeed it is a wrapper over HTTP_Request2_Response.
 */
class GG_API_Response {

	/**
	 * @var HTTP_Request2_Response
	 */
	private $httpResponse;

	/**
	 * @param HTTP_Request2_Response $httpResponse
	 */
	public function __construct($httpResponse) {
		$this->httpResponse = $httpResponse;
	}

	/**
	 * @return HTTP_Request2_Response
	 */
	public function getHttpResponse() {
		return $this->httpResponse;
	}

	/**
	 * Returns the HTTP status code.
	 *
	 * @return integer HTTP status code.
	 * @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
	 */
	public function getStatus() {
		return $this->httpResponse->getStatus();
	}

	/**
	 * Returns the body of the response.
	 *
	 * @return string
	 * @throws HTTP_Request2_Exception if body cannot be decoded.
	 */
	public function getBody() {
		return $this->httpResponse->getBody();
	}

	/**
	 * @return bool true if HTTP status code of response is 200.
	 */
	public function isOk() {
		return $this->getStatus() === 200;
	}
}

?>
